import Api from "../../request/api"
export default {
    namespaced: true,
    state: {
        goodslist: [],
        goodscount: 0,
        catelist: []
    },
    mutations: {
        initGoodsList(state, payload) {
            state.goodslist = payload
        },
        initGoodsCount(state, payload) {
            state.goodscount = payload
        },
        initCatelist(state, payload) {
            state.catelist = payload
        }
    },
    actions: {
        getgoodslist({
            commit
        }, payload) {
            Api.goodslist(payload).then(res => {
                if (res.code == 200) {
                    commit("initGoodsList", res.list)
                }
            })
        },
        getgoodscount({
            commit
        }) {
            Api.goodscount().then(res => {
                if (res.code == 200) {
                    commit("initGoodsCount", res.list[0].total)
                }
            })
        },
        //    二级的catelist
        getcatelist({
            commit
        }) {
            Api.catelist({
                commit
            }).then(res => {
                if (res.code == 200) {
                    commit("initCatelist", res.list)
                }
            })
        }
    },
    getters: {},

}